package com.task.common.enums;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.util.ObjectUtils;

/**
 * @Author 迪迦.
 * @Date 2023/5/18 17:41
 */
public enum WeekEnum {
  MONDAY(1, "monday", "星期一"),
  TUESDAY(2, "tuesday", "星期二"),
  WEDNESDAY(3, "wednesday", "星期三"),
  THURSDAY(4, "thursday", "星期四"),
  FRIDAY(5, "friday", "星期五"),
  SATURDAY(6, "saturday", "星期六"),
  SUNDAY(7, "sunday", "星期天"),

  ;

  private Integer info;
  private String displayName;
  private String msg;


  WeekEnum(Integer info, String displayName, String msg) {
    this.info = info;
    this.displayName = displayName;
    this.msg = msg;
  }

  public static WeekEnum getEnumByInfo(int info) {
    if (!ObjectUtils.isEmpty(info)) {
      for (WeekEnum value : WeekEnum.values()) {
        if (info == value.getInfo()) {
          return value;
        }
      }
    }
    return WeekEnum.MONDAY;
  }

  /**
   * 获取列表.
   */
  public static List<Map<String, Object>> getList() {
    List<Map<String, Object>> list = new ArrayList<>();
    for (WeekEnum value : WeekEnum.values()) {
      Map<String, Object> map = new HashMap<>();
      map.put("value", value.getInfo());
      map.put("label", value.getMsg());
      map.put("displayName", value.getDisplayName());
      list.add(map);
    }
    return list;
  }

  WeekEnum() {
  }

  public Integer getInfo() {
    return info;
  }

  public String getDisplayName() {
    return displayName;
  }

  public String getMsg() {
    return msg;
  }
}
